/*
* @Author: Administrator
* @Date:   2017-12-23 15:54:49
* @Last Modified by:   Administrator
* @Last Modified time: 2017-12-23 16:03:35
*/
import { observable, action } from 'mobx'
import NewsList from './new_list'
import NewsDetail from './news_detail'
import MobileNewsList from './mobile_newslist'
import User from './user_store'

class StateClass {
  constructor(initialState) {
    if (initialState && initialState.appState && initialState.appState.activeChannel) {
      this.activeChannel = initialState.appState.activeChannel
    } else {
      this.activeChannel = '首页'
    }
  }
  @observable activeChannel
  @action serActiveChannel(channel) {
    this.activeChannel = channel
  }
}
export default StateClass

const createStore = (initialState) => {//eslint-disable-line
  return {
    appState: new StateClass(initialState),
    newsList: new NewsList(initialState),
    newsDetail: new NewsDetail(initialState),
    mobileNewsList: new MobileNewsList(initialState),
  }
}
const createUserStore = (userInfo = {}) => {
  const userStore = new User(userInfo)
  return userStore
}
export {
  createStore,
  createUserStore,
}
